package red.book._1._1;

public class Stack<T> {
    private Node<T> first;
    private int N;

    private class Node<T>{
        Node<T> next;	
        T t;
    }

    public boolean isEmpty(){
        return first == null;
    }

	public void push(T t) {
		Node<T> oldFirst = first;
		first = new Node<T>();
		first.next = oldFirst;
		first.t = t;
		N++;
	}

    public T pop(){
        T oldFirst = first.t;
        first = first.next;
        N--;
        return oldFirst;
    }
}
